home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
TSRCOMM.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-09-09
|
63KB
|
2,061 lines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; TSRCOMM.ASM A Replacement for Interrupt 14
;;
;; Copyright 1987, Ross M. Greenberg
;;
;; This program is a terminate and stay resident program which allows
;; computers such as the IBM PC and compatibles using standard serial
;; communications calls to take advantage of the asynchronous interrupt
;; capabilities of the 8250 and 8259.
;;
;; The functionality with AH=0,1,2,3 remains the same as always
;;
;; With AH = 4, a new set of commands are now available.
;; Sub-functions are set in AL (See below for new function descriptions)
;;
;; To compile this program, you must have MASM 4.0 or a close relative,
;; and need only do:
;;
;; C> MASM TSRCOMM;
;; C> LINK TSRCOMM;
;; C> EXE2BIN TSRCOMM.EXE TSRCOMM.COM
;; C> DEL TSRCOMM.EXE
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MACRO DEFINITIONS
;;
DOSINT macro set_ah_to
mov ah, set_ah_to
int 21h
endm
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; CONSTANTS
;;
FALSE equ 00h
TRUE equ 01h
BELL equ 07h
ONE_SECOND equ 18 ; roughly 18 timer ticks
TWO_SECONDS equ ONE_SECOND * 2 ; same idea
THIRTY_SECONDS equ ONE_SECOND * 30 ;
TIMER_TICK_INT_NO equ 1ch ; some might set this to 08h
;; Send an XOFF when you wish the remote to stop sending and
;; send an XON when the remote is allowed to continue
;;
XOFF equ 13h ; a control-S
XON equ 11h ; a control-Q
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Define the size of the Communications Buffers
;;
;; You may want to change these to more accurately reflect your
;; actual needs. The high-water and low-water mark for XON/XOFF
;; processing are a function of the size of these two variables
P1_INLEN equ 400h
P2_INLEN equ 400h
P1_OUTLEN equ 400h
P2_OUTLEN equ 400h
;; Be careful with these settings if your have different lengths for each
;; of the COM_INBUF's: these only play off of COM1_INBUF
HIGH_MARK equ (P1_INLEN/10 * 8) ; send XOFF when buffer is
; 80% full
LOW_MARK equ (P1_INLEN/10 * 2) ; send XON when buffer is
; only 20% full
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Definitions of all of the 8250 Registers and their individual
;; bit meanings
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
DATA equ 0h ; DATA I/O is from the base
IER equ 1h ; Interrupt Enable Register
IER_RDA equ 1h ; Received Data Available interrupt bit
IER_THRE equ 2h ; Transmitter Holding Reg. Empty int bit
IER_RLS equ 4h ; Receive Line Status int bit
IER_MS equ 8h ; Modem Status int bit
IIR equ 2 ; Interrupt Identification Register
IIR_RLS equ 5h ; *equal* to if Receiver Line Status int
IIR_RDA equ 4h ; *equal* to if character ready
IIR_THRE equ 2h ; *equal* to if TX Buffer empty
IIR_PEND equ 1h ; set to zero if any interrupt pending
IIR_MS equ 0h ; *equal* to if Modem Status int
LCR equ 3h ; Line Control Register
LCR_WLS0 equ 0h ; Word Length Select Bit 0
LCR_WLS1 equ 1h ; Word Length Select Bit 1
LCR_STOPBITS equ 4h ; number of stop bits
LCR_PARITYEN equ 8h ; Enable Parity (see SPARITY & EPARITY)
LCR_EPARITY equ 10h ; Even Parity Bit
LCR_SPARITY equ 20h ; Stick Parity
LCR_BREAK equ 40h ; set if break is desired
LCR_DLAB equ 80h ; Divisor Latch Access Bit (baudrate setting)
MCR equ 4h ; Modem Control Register
MCR_DTR equ 1h ; Data Terminal Ready
MCR_RTS equ 2h ; Request To Send
MCR_OUT1 equ 4h ; Output 1 (nobody uses this!)
MCR_OUT2 equ 8h ; Out 2 (Sneaky Int enable in hware gates!)
MCR_LOOP equ 10h ; Loopback enable
LSR equ 5 ; Line Status Register
LSR_DATA equ 1h ; Data Ready Bit
LSR_OVERRUN equ 2h ; Overrun Error Bit
LSR_PARITY equ 4h ; Parity Error Bit
LSR_FRAMING equ 8h ; Framing Error Bit
LSR_BREAK equ 10h ; Break Detect (sometimes an error!)
LSR_THRE equ 20h ; Transmit Holding Register Empty
LSR_TSRE equ 40h ; Transmit Shift Register Empty
MSR equ 6 ; Modem Status Register
MSR_DEL_CTS equ 1h ; Delta Clear To Send
MSR_DEL_DSR equ 2h ; Delta Data Set Ready
MSR_EDGE_RI equ 4h ; Trailing Edge of Ring Indicator
MSR_DEL_SIGD equ 8h ; Delta Receive Line Signal Detect (delta DCD)
MSR_CTS equ 10h ; Clear To Send
MSR_DSR equ 20h ; Data Set Ready
MSR_RI equ 40h ; Ring Indicator - during the entire ring
MSR_DCD equ 80h ; Data Carrier Detect - Someone On-line
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The 8259 interrupt controller is at port I/O INT_CTRL
;; To reset from an interrupt, you must output an INT_EOI.
;;
;; To enable or disable interrupts for either of the com ports, read
;; the value on port INT_MASK_PORT, turn the appropriate COM1 or COM2 bit
;; on or off, and output the new mask back out the port.
;;
;;
CTRL_PORT equ 20h
INT_EOI equ 20h
;;
INT_MASK_PORT equ 21h
COM1_MASK equ 0efh
COM2_MASK equ 0f7h
INTNO_COM1 equ 0ch
INTNO_COM2 equ 0bh
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; These ports may or may not respond to the ports at base 40:0.
;; If they don't we'll refuse to run. Not at all subtle, but effective.
;; See the first Sidebar for more information
;;
PORT1 equ 3f8h
PORT2 equ 2f8h
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
code segment para ; align the code segment to the nearest
; paragraph boundary
assume cs:code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
org 2ch
env_ptr label word ; this points to the environment address
; as stored in the PSP. We'll free this
; in the startup routine.
org 100h ; COM programs always start at 100h
; just like CP/M!
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; START OF TSR CODE
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
start: jmp install
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; COMM PORT BLOCK (CPB)
;;
;; Comm Port Block defines information unique for each comm port
;; and includes information such as what the original interrupt
;; vector pointed to, which parameters are set, etc.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
CPB struc
cpb_base dw ? ; the base port of the comm port (2F8, 3F8)
cpb_nint_off dw ? ; new interrupt offset address
cpb_pic_mask db ? ; mask for enabling ints from 8259
cpb_int_no db ? ; what interrupt we are
cpb_mode dw ? ; whatever modes we have turned on
cpb_timeout dw ? ; indi